package com.lanqiao.testwork;

import java.util.Scanner;

public class Test28 {

	public static void main(String[] args) {
		test();
	}

	private static void test() {
		bubbleSort();
		insertSort();
	}

	/**
	 * 冒泡排序
	 */
	public static void bubbleSort() {
		int[] a = new int[10];
		Scanner in = new Scanner(System.in);
		for (int i = 0; i < a.length; i++) {
			a[i] = in.nextInt();
		}
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a.length - 1; j++) {
				if (a[j] > a[j + 1]) {
					a[j] = a[j] ^ a[j + 1];
					a[j + 1] = a[j] ^ a[j + 1];
					a[j] = a[j] ^ a[j + 1];
				}
			}
		}
		for (int i = 0; i < a.length; i++) {
			System.out.print(" " + a[i]);
		}
	}
	
	/**
	 * 插入排序
	 */
	public static void insertSort() {
		int[] a = new int[10];
		Scanner in = new Scanner(System.in);
		for (int i = 0; i < a.length; i++) {
			a[i] = in.nextInt();
		}
		for (int i = 0; i < a.length; i++) {
			int j = -1;
			while(j<=i && a[i] > a[++j]);
			if(j<i) {
				int temp = a[i];
				for (int k = i-1; k >= j; k--) {
					a[k+1] = a[k];
				}
				a[j] = temp;
			}
		}
		for (int i = 0; i < a.length; i++) {
			System.out.print(" " + a[i]);
		}
	}
}
